package apis

import (
	"google.golang.org/api/option"
)

type ApiClientConfig struct {
	EndPoint string
	APIKey   string
}

type ApiClientOptionFunc func(config *ApiClientConfig)

func (s *ApiClientConfig) GenLanguageOptions() (opts []option.ClientOption) {
	opts = append(opts, option.WithEndpoint(s.EndPoint))
	opts = append(opts, option.WithAPIKey(s.APIKey))
	return
}

func WithEndPoint(endPoint string) ApiClientOptionFunc {
	return func(config *ApiClientConfig) {
		config.EndPoint = endPoint
	}
}

func WithAPIKey(apiKey string) ApiClientOptionFunc {
	return func(config *ApiClientConfig) {
		config.APIKey = apiKey
	}
}

type EndPointProxy interface {
	GetEndPoint() string
}

func WithEndPointProxy(proxy EndPointProxy) ApiClientOptionFunc {
	return func(config *ApiClientConfig) {
		config.EndPoint = proxy.GetEndPoint()
	}
}

type APIKeyProxy interface {
	GetAPIKey() string
}

func WithAPIKeyProxy(proxy APIKeyProxy) ApiClientOptionFunc {
	return func(config *ApiClientConfig) {
		config.APIKey = proxy.GetAPIKey()
	}
}
